package com.briup.demo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.demo.bean.CmsLink;
import com.briup.demo.mapper.CmsLinkMapper;

@Service
public class CmsLinkService {

	@Autowired
	private CmsLinkMapper linkMapper;
	
	public int deleteById(int id) {
		return linkMapper.deleteByPrimaryKey(id);	
	}
	
	public int deleteByIds(int[] ids) {
		int num = 0;
		for(int id:ids) {
			deleteById(id);
			num++;
		}
		return num;
	}	
	
	public List<CmsLink> selectAll(){
		List<CmsLink> list = linkMapper.selectAll();
		return list;
	}
	
	public int saveOrUpdate(CmsLink link) {
		CmsLink c = linkMapper.selectByPrimaryKey(link.getId());
		if(c==null)
		{
			return linkMapper.insert(link);
		}else {
			return linkMapper.updateByPrimaryKey(link);
		}	
	}
	
}
